<? require("../header.inc"); ?>
<? require("../db.php"); ?>

<?
$TableName = $_GET["TableName"];
if ($TableName == "") $TableName = $_POST["TableName"];
if ($TableName = "") $TableName = "$MainSupportTree";
$FromNode = $_GET["FromNode"];
if  ($FromNode == "") $FromNode = $_GET["FromNode"];
if ($FromNode == "")  $FromNode = $_POST["FromNode"];
if ($FromNode == "") $FromNode = 1;
$Link = "";
$db = connectdb();
$SQLQ = "SELECT * FROM SupportCategories WHERE CategoryID =" . $FromNode . ";";
$result = mysql_query($SQLQ);
  	if ($myrow = mysql_fetch_array($result))
{
$AuthorList = $myrow['AuthorList'];
}

if ($_POST["CatName"] != "") 
{
	$CatName = $_POST["CatName"];
	$HomePage = $_POST["HomePage"];
	$AuthorList = $_POST["AuthorList"];
	$INSERTSTR = "INSERT INTO SupportCategories (CategoryName,HomePage,AuthorList) VALUES ('$CatName','$HomePage','$AuthorList');";
	$r = mysql_query($INSERTSTR);
	if (!($r)) 
		echo "Sorry, error entering data: $INSERTSTR";
	else
		header ("Location: /troubleshooter/tsadditem.php?TableName=$TableName&NodeID=$FromNode");
}
//Write record to DB and return !

else
{

?>

<HTML>
<HEAD>
<STYLE TYPE="text/css">

body	{filter: progid:DXImageTransform.Microsoft.gradient(enabled='true',
                startColorstr=#00FFFFFF, endColorstr=#FFE0DFE3); height:100%; width:100%;

}

H1	{
	font: normal 175% Trebuchet MS;
	margin-top: 1em;
	margin-left: 30px;
	margin-bottom: -.7em;
	color: #9999CC;
}

p.Welcome	{
			font: 105% Verdana;
		 	color: #666699;
		 	margin-left: 3em;
			margin-top: 1em;
			margin-right: 4em;
}
</STYLE>

</HEAD>
<BODY>

<P>Add Category: </P>

Add Category to Support Tree: <? echo $TableName; ?> 
<HR>
<FORM ACTION="tsmakecat.php" METHOD="POST">
<TABLE>
<TD>Category Name: </TD> <TD> <INPUT TYPE="textbox" size=50 name="CatName"></TD>
<TR>
<TD>Redirect: </TD> <TD> <INPUT TYPE="textbox" size=50 name="redirect"></TD>
<TR>
<TD>&nbsp;</TD><TD> Above: Address to redirect if user chooses "My problem is not one of above." </TD>
<TR>
<TD>Authors: </TD> <TD> <INPUT TYPE="textbox" size=50 name="Authors" Value="<? echo $AuthorList ?>"></TD>
<TR>
<TD>&nbsp;</TD><TD> Comma separated List of users who can add items to this list." </TD>
</TABLE>
<CENTER>
<INPUT Type="hidden" name="FromNode" value="<? echo $FromNode; ?>">
<INPUT Type="hidden" name="TableName" value="<? echo $TableName; ?>">
<INPUT Type="submit" name="submit" value = "Add Category">
</CENTER>
</FORM>
<FONT FACE = "Arial">
<P>
</FONT>
</BODY>
</HTML>
<? } ?>
	